import { http } from "@/utils/http";
import { baseUrlApi } from "@/api/utils";

export interface ShortVideo {
  id: number;
  source: string;
  source_id: string;
  category_id: number;
  category: string;
  title: string;
  cover: string;
  remark: string;
  author: string;
  duration: number;
  play_url: string;
  tags: string[];
  selling_points: string;
  is_vertical: boolean;
  status: number;
  incoming_time: string;
  show_time: string;
  copyright_expiry: string;
  created_at: string;
  updated_at: string;
}

export const getShortVideoList = (params?: object) => {
  return http.request<ApiResultPage<ShortVideo>>(
    "get",
    baseUrlApi("short_video"),
    {
      params
    }
  );
};

export const getShortVideoInfo = (id: number) => {
  const url = `short_video/${id}`;
  return http.request<ApiResult<ShortVideo>>("get", baseUrlApi(url), {});
};

export const createShortVideo = (data: ShortVideo) => {
  return http.request<ApiResult<ShortVideo>>(
    "post",
    baseUrlApi("short_video"),
    {
      data
    }
  );
};

export const updateShortVideo = (data: ShortVideo) => {
  const url = `short_video/${data.id}`;
  return http.request<ApiResult<ShortVideo>>("put", baseUrlApi(url), {
    data
  });
};

export const deleteShortVideo = (id: number) => {
  const url = `short_video/${id}`;
  return http.request<ApiResult<ShortVideo>>("delete", baseUrlApi(url));
};
